<?php

namespace app\exception;

use Throwable;
use support\exception\Handler;
use think\exception\ValidateException;
use Webman\Http\Request;
use Webman\Http\Response;

class BaseHandler extends Handler
{
    public $dontReport = [
        ValidateException::class,
    ];

    public function render(Request $request, Throwable $exception): Response
    {
        if ($exception instanceof ValidateException) {
            return json([
                'code' => 400,
                'msg' => $exception->getMessage(),
            ]);
        }
        return parent::render($request, $exception);
    }
}
